<template>
  <!-- 添加或修改角色配置对话框 -->
  <el-dialog v-loading="loading" :title="title" :visible.sync="open" width="850px">
    <el-form ref="form" :model="propFormData" label-width="100px" size="mini">
      <el-row>
        <el-col :span="12">
          <el-form-item label="入职者姓名" prop="joberName">
            {{ propFormData.joberName }}
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="岗位" prop="technologyId">
            {{ ifWorkType(propFormData.technologyId) }}
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="电话" prop="jobberPhone">
            {{ propFormData.jobberPhone }}
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="推荐人" prop="recUserName">
            {{ propFormData.recUserName }}
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="面试人" prop="viewUserName">
            {{ propFormData.viewUserName }}
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="预约时间" prop="makeTime">
            {{ parseTime(propFormData.makeTime) }}
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="状态" prop="jobberStatic">
            {{ propFormData.jobberStatic | fltStatic }}
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="流程进度" prop="flowId">
            {{ propFormData.flowStatic | fltFlowStatic }}
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="推荐评语" prop="recRemark">
            {{ propFormData.recRemark }}
          </el-form-item>
        </el-col>
        <el-col :span="24" v-if="propFormData.chooseRemark">
          <el-form-item label="筛选评语" prop="chooseRemark">
            {{ propFormData.chooseRemark }}
          </el-form-item>
        </el-col>
        <el-col :span="24" v-if="propFormData.jobRemark">
          <el-form-item label="面试评语" prop="jobRemark">
            {{ propFormData.jobRemark }}
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="简历下载" prop="resumeUpload">
            <a @click="handleDownLondFn" style="cursor: pointer;">点击下载</a>
            <!-- <a target='_black' :href="'http://view.officeapps.live.com/op/view.aspx?src=' +  encodeURIComponent(propFormData.vitaeUrl)" style="cursor: pointer;">在线阅览</a> -->
            <!-- {{ propFormData.techonlogyId }} -->
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
  </el-dialog>
</template>

<script>
  import { apiRequestDetail } from "../../../../api/pmp/api.recruit";

  export default {
    name: 'recruitDetail', //详情页面
    props: {
      id: {
        type: String,
        default: ""
      }
    },
    data () {
      return {
        // 遮罩层
        loading: true,
        // 弹出层标题
        title: "",
        // 是否显示弹出层
        open: false,
        // 表单
        propFormData: {}
        // techonlogyData: []
      };
    },
    filters: {
      fltStatic (val) {
        switch (+val){
        case 1:
          return '未开始';
          break;
        case 2:
          return '进行中';
          break;
        case 3:
          return '已结束';
          break;
        default:
          // statements_def
          break;
        }
      },
      fltFlowStatic (val) {
        switch (+val){
        case 1:
          return '待筛选';
          break;
        case 2:
          return '筛选未通过';
          break;
        case 3:
          return '待预约';
          break;
        case 4:
          return '面试中';
          break;
        case 5:
          return '面试未通过';
          break;
        case 6:
          return '入职待定';
          break;
        case 7:
          return '已结束';
          break;
        default:
          return '未开始';
          // statements_def
          break;
        }
      },
    },
    computed: {
      ifWorkType () {
        return (val)=> {
          return (this.$parent.workTypeData.find((item) => item.dictValue == val) || {}).dictLabel;
        };
      }
    },
    watch: {
      id(val){
        if(this.id){
          this.loading = true;
          apiRequestDetail(this.id).then(response => {
            this.propFormData = response.data;
            this.loading = false;
          });
        }
      }
    },
    methods: {
      // 取消按钮
      cancelFn() {
        this.open = false;
      },
      // 打开页面
      openDetail(){
        // 根据数据的状态属性，页面交互会发生变化
        this.open = true;
      },
      /** 下载 */
      handleDownLondFn() {

        var link = document.createElement('a');
        //设置下载的文件名
        link.download = this.propFormData.joberName+'简历.doc';
        link.style.display = 'none';
        //设置下载路径
        link.href = this.propFormData.vitaeUrl;
        //触发点击
        document.body.appendChild(link);
        link.click();
        //移除节点
        document.body.removeChild(link);
      }
    }
  };
</script>
